part of '../repository.dart';

const _kWebBankCardTypeVisaValue = 'visa';
const _kWebBankCardTypeMastercardValue = 'mastercard';
const _kWebBankCardTypeMirValue = 'mir';
const _kWebBankCardTypeUnionPayValue = 'unionPay';
const _kWebBankCardTypeJcbValue = 'jcb';
const _kWebBankCardTypeAmericanExpressValue = 'american_express';
const _kWebBankCardTypeDinersClubValue = 'diners_club';
const _kWebBankCardTypeDiscoverCardValue = 'discover_card';
const _kWebBankCardTypeInstaPaymentValue = 'insta_payment';
const _kWebBankCardTypeInstaPaymentTMValue = 'insta_payment_tm';
const _kWebBankCardTypeLaserValue = 'laser';
const _kWebBankCardTypeDankortValue = 'dankort';
const _kWebBankCardTypeSoloValue = 'solo';
const _kWebBankCardTypeSwitchValue = 'switch';
const _kWebBankCardTypeUnknownValue = 'unknown';

class _WebBankCardTypeDto extends Equatable {
  const _WebBankCardTypeDto._internal({
    required this.bankCardTypeString,
  });

  final String bankCardTypeString;

  @override
  List<Object?> get props {
    return [
      bankCardTypeString,
    ];
  }

  factory _WebBankCardTypeDto.fromString(String bankCardTypeString) {
    return _WebBankCardTypeDto._internal(
      bankCardTypeString: bankCardTypeString,
    );
  }

  factory _WebBankCardTypeDto.fromEntity(WebBankCardType bankCardType) {
    late final String bankCardTypeString;

    if (bankCardType == WebBankCardType.visa) {
      bankCardTypeString = _kWebBankCardTypeVisaValue;
    } else if (bankCardType == WebBankCardType.mastercard) {
      bankCardTypeString = _kWebBankCardTypeMastercardValue;
    } else if (bankCardType == WebBankCardType.mir) {
      bankCardTypeString = _kWebBankCardTypeMirValue;
    } else if (bankCardType == WebBankCardType.unionPay) {
      bankCardTypeString = _kWebBankCardTypeUnionPayValue;
    } else if (bankCardType == WebBankCardType.jcb) {
      bankCardTypeString = _kWebBankCardTypeJcbValue;
    } else if (bankCardType == WebBankCardType.americanExpress) {
      bankCardTypeString = _kWebBankCardTypeAmericanExpressValue;
    } else if (bankCardType == WebBankCardType.dinersClub) {
      bankCardTypeString = _kWebBankCardTypeDinersClubValue;
    } else if (bankCardType == WebBankCardType.discoverCard) {
      bankCardTypeString = _kWebBankCardTypeDiscoverCardValue;
    } else if (bankCardType == WebBankCardType.instaPayment) {
      bankCardTypeString = _kWebBankCardTypeInstaPaymentValue;
    } else if (bankCardType == WebBankCardType.instaPaymentTM) {
      bankCardTypeString = _kWebBankCardTypeInstaPaymentTMValue;
    } else if (bankCardType == WebBankCardType.laser) {
      bankCardTypeString = _kWebBankCardTypeLaserValue;
    } else if (bankCardType == WebBankCardType.dankort) {
      bankCardTypeString = _kWebBankCardTypeDankortValue;
    } else if (bankCardType == WebBankCardType.solo) {
      bankCardTypeString = _kWebBankCardTypeSoloValue;
    } else if (bankCardType == WebBankCardType.switchCard) {
      bankCardTypeString = _kWebBankCardTypeSwitchValue;
    } else if (bankCardType == WebBankCardType.unknown) {
      bankCardTypeString = _kWebBankCardTypeUnknownValue;
    }

    return _WebBankCardTypeDto._internal(
      bankCardTypeString: bankCardTypeString,
    );
  }

  @override
  String toString() {
    return bankCardTypeString;
  }

  WebBankCardType toEntity() {
    if (bankCardTypeString == _kWebBankCardTypeVisaValue) {
      return WebBankCardType.visa;
    }

    if (bankCardTypeString == _kWebBankCardTypeMastercardValue) {
      return WebBankCardType.mastercard;
    }

    if (bankCardTypeString == _kWebBankCardTypeMirValue) {
      return WebBankCardType.mir;
    }

    if (bankCardTypeString == _kWebBankCardTypeUnionPayValue) {
      return WebBankCardType.unionPay;
    }

    if (bankCardTypeString == _kWebBankCardTypeJcbValue) {
      return WebBankCardType.jcb;
    }

    if (bankCardTypeString == _kWebBankCardTypeAmericanExpressValue) {
      return WebBankCardType.americanExpress;
    }

    if (bankCardTypeString == _kWebBankCardTypeDinersClubValue) {
      return WebBankCardType.dinersClub;
    }

    if (bankCardTypeString == _kWebBankCardTypeDiscoverCardValue) {
      return WebBankCardType.discoverCard;
    }

    if (bankCardTypeString == _kWebBankCardTypeInstaPaymentValue) {
      return WebBankCardType.instaPayment;
    }

    if (bankCardTypeString == _kWebBankCardTypeInstaPaymentTMValue) {
      return WebBankCardType.instaPaymentTM;
    }

    if (bankCardTypeString == _kWebBankCardTypeLaserValue) {
      return WebBankCardType.laser;
    }

    if (bankCardTypeString == _kWebBankCardTypeDankortValue) {
      return WebBankCardType.dankort;
    }

    if (bankCardTypeString == _kWebBankCardTypeSoloValue) {
      return WebBankCardType.solo;
    }

    if (bankCardTypeString == _kWebBankCardTypeSwitchValue) {
      return WebBankCardType.switchCard;
    }

    if (bankCardTypeString == _kWebBankCardTypeUnknownValue) {
      return WebBankCardType.unknown;
    }

    throw UnimplementedError();
  }
}
